package servlet;

import server.HttpProtocolUtil;
import server.HttpServlet;
import server.Request;
import server.Response;

import java.io.IOException;

/**
 * @author: liufh
 * @create: 2021-10-12 11:39
 */
public class WebServlet extends HttpServlet {

    @Override
    public void doGet(Request req, Response resp) {
        System.out.println("====WebServlet demo02 的 doGet方法执行中...");
        String content = "<h1>WebServlet demo02 get</h1>";
        try {
            resp.output((HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request req, Response resp) {
        System.out.println("====WebServlet02 demo 的 doPost方法执行中...");
    }

    public void init() throws Exception {

    }

    public void destory() throws Exception {

    }
}
